package cn.tedu.luban.worker.main.repository.impl;

import cn.tedu.luban.worker.main.converter.WorkerAuditConverter;
import cn.tedu.luban.worker.main.dao.WorkerAuditLogDAO;
import cn.tedu.luban.worker.main.repository.WorkerAuditRepository;
import cn.tedu.luban.worker.protocol.bo.AdminAuditBO;
import cn.tedu.luban.worker.protocol.dos.WorkerAuditLogDO;
import cn.tedu.luban.worker.protocol.param.AuditSubmitParam;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class WorkerAuditRepositoryImpl implements WorkerAuditRepository {
    @Autowired(required = false)
    private WorkerAuditLogDAO workerAuditLogDAO;
    @Autowired
    private WorkerAuditConverter workerAuditConverter;
    @Override public List<AdminAuditBO> getWorkerAuditLogs(Long userId) {
        List<WorkerAuditLogDO> workerAuditLogDOS= workerAuditLogDAO.selectWorkerAuditLogs(userId);
        return workerAuditConverter.dos2bos(workerAuditLogDOS);
    }

    @Override public Long save(AuditSubmitParam param) {
        WorkerAuditLogDO workerAuditLogDO=workerAuditConverter.param2do(param);
        workerAuditLogDAO.insert(workerAuditLogDO);
        return workerAuditLogDO.getId();
    }
}
